From 05245a00eefbd52cfec472b649ae8bb646133eac Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 25 Mar 2015 12:51:23 -0700 Subject: [PATCH] Fix an erroneous assertion in `cargo doc` --- src/cargo/ops/cargo_doc.rs | 2 +- tests/test_cargo_doc.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_doc.rs b/src/cargo/ops/cargo_doc.rs index fdfe8e3f6..eb633f604 100644 --- a/src/cargo/ops/cargo_doc.rs +++ b/src/cargo/ops/cargo_doc.rs @@ -24,7 +24,7 @@ pub fn doc(manifest_path: &Path, let mut lib_names = HashSet::new(); let mut bin_names = HashSet::new(); if options.compile_opts.spec.is_none() { - for target in package.targets() { + for target in package.targets().iter().filter(|t| t.documented()) { if target.is_lib() { assert!(lib_names.insert(target.name())); } else { diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 27fb250e5..8f0c23ce6 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -245,3 +245,20 @@ test!(doc_dash_p { {compiling} a v0.0.1 (file://[..]) ", compiling = COMPILING).as_slice())); }); + +test!(doc_same_name { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + "#) + .file("src/lib.rs", "") + .file("src/bin/main.rs", "fn main() {}") + .file("examples/main.rs", "fn main() {}") + .file("tests/main.rs", "fn main() {}"); + + assert_that(p.cargo_process("doc"), + execs().with_status(0)); +}); -- 2.30.2